function addEvent(el, type, fn){
    if(el.addEventListener){
        el.addEventListener(type, fn, false);
    }else if(el.attachEvent){
        el.attachEvent('on' + type,function(){
            handle.call(el);
        })
    }else{
        el['on' + type] = fn;
    }
}

Date.prototype.Format = function (fmt) { //author: meizz
    var o = {
        "M+": this.getMonth() + 1, //月份
        "d+": this.getDate(), //日
        "h+": this.getHours(), //小时
        "m+": this.getMinutes(), //分
        "s+": this.getSeconds(), //秒
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
        "S": this.getMilliseconds() //毫秒
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}


//获取Url参数
RequestURLParam = {
    getParam: function (name) {
        var lurl = window.location.href;
        if (lurl.indexOf(name) < 0) return;
        if (lurl.indexOf("?") < 0) {
            return "";
        } else {
            var value;
            var str = location.href; //取得整个地址栏
            var num = str.indexOf("?")
            str = str.substr(num + 1); //取得所有参数   stringvar.substr(start [, length ]
            var arr = str.split("&"); //各个参数放到数组里
            for (var i = 0; i < arr.length; i++) {
                num = arr[i].indexOf("=");
                if (num > 0 && arr[i].substring(0, num) == name) {
                    return value = arr[i].substr(num + 1);
                }
            }
            return "";
        }
    }
}

/**
 * 提交Action请求
 * 参数url请求action;dataPrms参数;callback回调函数,post提交方式post或者get,ayn异步设置,objControl对象控制为true时 action处理完之前对象不可用，showTilte显示标题信息，showMask显示内容
 */
function ActHttpRequest(url, dataPrms, callback, post, ayn, objControl, showTilte, showMask) {
    var operatTxt = "加载中";
    if (showTilte && showTilte.length > 0) {
        operatTxt = showTilte;
    }
    var postTxt = "post";
    if (post) {
        postTxt = post;
    }
    var aynTxt = false;
    if (ayn) {
        aynTxt = true;
    }
    if (showMask) {
        // mini.mask({
        //     el: document.body,
        //     cls: 'mini-mask-loading',
        //     html: operatTxt + '...'
        // });
    }
    $.ajax({
        async: aynTxt,
        type: postTxt,
        url: url,
        data: dataPrms,
        dataType:"json",
        contentType:'application/x-www-form-urlencoded; charset=UTF-8',
        timeout: 60000,//超时时间设置为1分钟；
        success: function (data, textStatus) {
            if (showMask) {
                //mini.unmask(document.body);
            }
            callback(data);
        },
        complete: function (XMLHttpRequest, textStatus) {
            if (showMask) {
                //mini.unmask(document.body);
            }
            if (objControl && objControl.attr) {
                objControl.attr("disabled", false);
            }
        },
        error: function (a, b, c) {
            // 请求出错处理,依然初始化咨询节点信息
            if (b == 'timeout') {
                //mini.alert("请求超时，请再次尝试！");
            } else {
                //mini.alert(url + "请求异常");
            }
        }
    });
}